#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int getLucky(vector<int> &x ,int n ,int pos,int sum,int mul)
{
    int count = 0;
    for(int i = pos;i < n;++i)
    {
        sum += x[i];
        mul *= x[i];
        //判断幸运与否
        if(sum > mul)
        {
            count += 1 + getLucky(x,n,i+1,sum,mul);
        }
        else if(x[i] == 1)
            count += getLucky(x,n,i+1,sum,mul);
        else
            break;//回溯

        sum -= x[i];
        mul /= x[i];

        //去重
        while(i < n-1 && x[i] == x[i+1])
            ++i;
    }
    return count;
}

int main()
{
    int n;
    while(cin >> n)
    {
        vector<int> x(n);
        for(int i = 0;i < n;++i)
        {
            cin >> x[i];
        }
        sort(x.begin(),x.end());
        cout << getLucky(x,n,0,0,1) << endl;
    }
    return 0;
}

